package com.hulk.ratel.common.exception;

import com.hulk.ratel.common.constant.enums.BussErrCode;
import lombok.Getter;
import lombok.Setter;

/**
 * @author hulk
 * @version 2014-1-21 下午10:53:55 
 */
public class BaseRteException extends RuntimeException {

	
	private static final long serialVersionUID = -1L;
	/** 错误结果代码 */
	@Getter
	@Setter
	private int errorCode;
	/** 错误信息 */
	@Getter
	@Setter
	private String errorMessage;
	
	/** 内部交易代码 */
	@Getter
	@Setter
	protected String intTxnSeq;

	/*业务信息，可能为空，参见com.hulk.aggregationplus.persistence.entity.TLogPubErrorRecord*/
	@Getter
	@Setter
	protected String errorRecordJson;


	/**
	 * 构造函数
	 * @param errorCode
	 *            错误代码
	 * @param throwable
	 *            Throwable
	 */
	public BaseRteException(int errorCode, Throwable throwable) {
		super(throwable.getMessage());
		this.errorCode = errorCode;
		this.errorMessage = throwable.getMessage();
	}

	/**
	 * 构造函数
	 * @param errorCode
	 *            错误代码
	 * @param errorMessage
	 *            错误信息
	 */
	public BaseRteException(int errorCode, String errorMessage) {
		super(errorMessage);
		this.errorCode = errorCode;
		this.errorMessage = errorMessage;
	}



	/**
	 * 构造函数
	 * @param errorCode
	 *            错误代码
	 * @param errorMessage
	 *            错误信息
	 * @param throwable
	 */
	public BaseRteException(int errorCode, String errorMessage,
			Throwable throwable) {
		super(errorMessage, throwable);
		this.errorCode = errorCode;
		this.errorMessage = errorMessage;
	}

	public BaseRteException(BussErrCode bussErrCode) {
		super(bussErrCode.getErrDesc());
		this.errorCode = bussErrCode.getErrCode();
		this.errorMessage = bussErrCode.getErrDesc();

	}
	public BaseRteException(BussErrCode bussErrCode,Throwable throwable) {
		super( bussErrCode.getErrDesc(), throwable);
		this.errorCode = bussErrCode.getErrCode();
		this.errorMessage = bussErrCode.getErrDesc();
	}
}
